/**
 * Created by WEN on 2016/10/9.
 */
public class SameTree {
    public boolean isSameTree(TreeNode p, TreeNode q) {
        if(p==null){
            if(q==null)
                return true;
            else return false;
        }else{
            if(q==null)
                return false;
            else if(p.val==q.val){
                return isSameTree(p.left,q.left)&&isSameTree(p.right,q.right);
            }else
                return false;
        }
    }
}
